﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
    public class cthdDAL:ketnoi
    {
        public bool cthdnhap_them(VO.cthd data)
        {
            try
            {
                using (SqlCommand dbCmd = new SqlCommand("Cthd_Insert", GetConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@MaNCC", data.Mahd));
                    dbCmd.Parameters.Add(new SqlParameter("@mahd", data.Mas));
                    dbCmd.Parameters.Add(new SqlParameter("@ngaynhap", data.Tens));
                    dbCmd.ExecuteNonQuery();
                }
            }
            catch
            {

            }

            return true;
        }
        public bool cthdnhap_sua(VO.cthd data)
        {
            using (SqlCommand dbCmd = new SqlCommand("Cthd_Update", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@mahd", data.Mahd));
                dbCmd.Parameters.Add(new SqlParameter("@mas", data.Mas));
                dbCmd.Parameters.Add(new SqlParameter("@tens", data.Tens));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }
        public bool cthdnhap_xoa(VO.cthd data)
        {
            using (SqlCommand dbCmd = new SqlCommand("Cthd_Delete", GetConnection()))
            {
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@mahd", data.Mahd));
                dbCmd.ExecuteNonQuery();
            }

            return true;
        }
        public DataTable cthdnhap_xem()
        {
            DataTable dt = new DataTable();
            using (SqlCommand dbCmd = new SqlCommand("Cthd_SelectAll", GetConnection()))
            {
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.ExecuteNonQuery();
                da.Fill(dt);
            }
            return dt;
        }
    }
}
